<template>
  <div class="survey-detail">
    <div class="survey-infos">
      <div class="survey-text">
        <p>事件类型：</p>
        <p>发现时间：{{event['采样日期']}}</p>
        <p>发现数量：{{event['定量样数量']}}</p>
        <p>网格编号：{{event['调查网格编号']}}</p>
        <p>区域：</p>
        <p>地址：{{event['小地名']}}</p>
        <p>生境类型：{{event['生态系统类型']}}</p>
        <p>北纬：{{event['纬度']}}</p>
        <p>东经：{{event['经度']}}</p>
      </div>
      <div class="survey-map">
        <Guiji style="height: 400px" :gpxFile="`http://36.152.9.59:8090/single_gpx/${event['轨迹文件名']}`"/>
      </div>
    </div>

    <el-divider></el-divider>

    <div class="survey-picture" v-if="pics && pics.length">
      <swiper class="el-swiper" :options="swiperOption">
        <swiper-slide v-for="(url, idx) in pics" :key="idx">
          <img
            class="swiper-image"
            :src="`http://36.152.9.59:8090/single_img/?url=${url}&dw=300&dh=300`"
          />
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
        <div class="swiper-button-prev" slot="button-prev"></div>
        <div class="swiper-button-next" slot="button-next"></div>
      </swiper>
    </div>
    <el-empty v-else description="暂无图片数据"></el-empty>
  </div>
</template>

<script>
import Guiji from '@/components/guiji'

import {isValidJson} from '@/utils'
export default {
  name: 'PageSurveyDetail',
  components: {
    Guiji,
  },
  props: {
    event: Object
  },
  data() {
    return {
      swiperOption: {
        loop: true,
        slidesPerView: 5,
        spaceBetween: 20,
        pagination: {
          el: '.swiper-pagination',
          clickable: true
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev'
        }
      }
    }
  },
  computed: {
    pics(){
      const ret = isValidJson(this.event['照片文件名'].replaceAll('\'', '"')) ? JSON.parse(this.event['照片文件名'].replaceAll('\'', '"')) : []
      return ret
    },
  },
  methods: {

  },
  created() {
    console.log('PageSurveyDetail created')
  },
}
</script>

<style lang="scss">
.survey-detail{

  .title-divider{
    margin: 15px 0;
  }
  .survey-infos{
    display: flex;
    .survey-text{
      flex: 1;
      min-width: 0;
      line-height: 24px;
    }
    .survey-map{
      flex: 1;
      min-width: 0;
    }
  }
}


.el-swiper{
  .swiper-slide{
    .swiper-image{
      display: block;
      width: 100%;
      border-radius: 4px;
      box-shadow: 0 0 4px rgba(0,0,0, .5);
    }
  }
  .swiper-button-prev, .swiper-button-next{
    transform: scale(0.5);
  }
  .swiper-pagination-bullet-active{
    box-shadow: 2px 2px 2px rgba(0,0,0, .5);
    background-color: #fff;
  }
}
</style>